﻿using System;
using System.Web;
using System.IO;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;


namespace AnyOffice.module.html_model
{
    public partial class index : BasePage
    {
        public StringBuilder strTemplate;

        protected void Page_Load(object sender, EventArgs e)
        {
            this.strTemplate = new StringBuilder();
            string[] files = Directory.GetFiles(Server.MapPath("./view"));
            if (files.Length > 0)
            {
                for (int i = 0; i < files.Length; i++)
                {
                    FileStream stream = new FileStream(files[i], FileMode.Open, FileAccess.Read);
                    StreamReader reader = new StreamReader(stream, Encoding.Default);
                    FileInfo info = new FileInfo(files[i]);
                    info.Refresh();
                    this.strTemplate.Append("<tr class=TableControl>");
                    this.strTemplate.Append("<td class=menulines align=center onclick=javascript:click_model('CONTENT_" + i.ToString() + "') style=cursor:hand>");
                    this.strTemplate.Append(info.Name);
                    this.strTemplate.Append("<input type='hidden' name='CONTENT_" + i.ToString() + "' value=\"");
                    this.strTemplate.Append(reader.ReadToEnd().Replace("\"", ""));
                    this.strTemplate.Append("\">");
                    this.strTemplate.Append("</td>");
                    this.strTemplate.Append("</tr>");
                    this.strTemplate.Append(reader.ReadToEnd());
                    reader.Close();
                    stream.Close();
                }
                this.litTemplate.Text = this.strTemplate.ToString();
            }
            else
            {
                this.strTemplate.Append("<tr class=TableControl><td class=menulines align=center>暂无模板</td></tr>");
            }


        }
    }
}
